Skip to content

«Tests» and «Visualisieren» store the block like ▶ (P29) - #27

Merged
cedricvogel-leo merged 1 commit into
mainfrom
fix/tests-store-block
Nov 1, 2026
Merged

cedricvogel-leo merged 1 commit into
mainfrom
fix/tests-store-block

Conversation

@cedricvogel-leo

Copy link
Copy Markdown
Collaborator

P29: until now a block was only stored after ▶. A learner who pressed only «Tests», the main button in Etappe 2, lost the change on reload.

How it works

  • ▶ already clicked LiaScript's hidden run button. LiaScript then stores the block (a new entry in its code history, kept across a reload and, from version: 1.0.0 on, across closing the tab) and runs the per-run script, which calls session.run(source).
  • «Tests» and «Visualisieren» now click that button too. Before the click they note their command in the session (commandAfterLiaRun).
  • run, called by the per-run script, then sends that command instead of glpython:run. Python runs once, and the console shows what it showed before.
  • The per-run script and the embed are unchanged, so no protocol change and no glpython-editor PR.
  • A note older than 10 seconds is dropped, in case LiaScript doesn't run the block. Without LiaScript's button (no code block), the command goes to glpython directly, as before.
  • The course's @Notiz stores its fields the same way (it clicks LiaScript's run button).
  • Unchanged code: LiaScript itself adds no new version when the code didn't change (measured below).
  • Several files (-noten.py / +main.py): LiaScript stores the whole group, as with ▶.
  • Blocks without features=tests: unchanged. «Visualisieren» stores there too.
  • README: one sentence in the section on ▶ and LiaScript's code history. No new texts.

Tested in LiaScript

Hosted player in Chrome. A course with version: 1.0.0, this macro served locally, the deployed embed. Inside the embed frame I recorded every message from the macro, to count runs.

Step Single block Group noten.py + main.py
Change, then only «Tests» version 0 → 1; messages ["glpython:test"]; console «Programm läuft · 1 von 1 Beispielen bestanden» (output once, report once) 0 → 1; ["glpython:test"]; «Hauptprogramm · 1 von 1 …»
«Tests» again, unchanged stays 1; ["glpython:test"] stays 1
Reload change there, version 1 change there
Change, then «Visualisieren» → 2; ["glpython:visualize"] → 2; ["glpython:visualize"]
Reload change there change there
Change, then ▶ → 3; ["glpython:run"] → 3; ["glpython:run"]
Reload change there change there

Before (macro on main), same test: after «Tests» and «Visualisieren» the version stays at 0, and after a reload the change is gone.

check-macro passes.

Your manual tests

  1. Chrome, desktop, a course with version: 1.0.0 (Etappe 2):
    • Change a block, press only «Tests», reload: the change is there, the version arrows show a new entry, and the console shows the program's output and the report once.
    • «Tests» again without a change: no new version.
  2. «Visualisieren» the same way: change, «Visualisieren», reload.
  3. ▶ as before.
  4. A block group (-noten.py / +main.py): change noten.py, «Tests», reload. The change is kept.
  5. A block with a profile without tests (e.g. @Code.erkunden): «Visualisieren» stores it.
  6. iPad: 1 and 2. Then close the tab and open the course again: the change is still there (version: 1.0.0).

Follow-ups

  • 10-second window: if LiaScript takes longer than 10 seconds to run the block after the click (I've never seen it), the note expires. Then that click runs the program instead of testing it; the code is still stored.
  • Buttons inside the embed («Beispiel visualisieren» for a failing example, «Visualisieren» on a REPL entry) still go directly to glpython. They don't change the code, so there's nothing to store.

🤖 Generated with Claude Code

LiaScript stores a code block (a new entry in its code history, kept
across a reload and, from a course's version 1.0.0 on, across closing the
tab) when the block runs through its own run action. ▶ clicks LiaScript's
hidden run button; «Tests» and «Visualisieren» talked to glpython directly,
so a learner who only pressed «Tests» lost the change on reload.

Now they click LiaScript's run button too, with the command they stand for
noted in the session. LiaScript's per-run script calls session.run as
before, and run then sends that command instead of a run - Python runs
once, and the console shows what it showed before. LiaScript adds no
version for unchanged code. A note older than 10 seconds is dropped;
without LiaScript's button the command goes to glpython directly.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cedricvogel-leo
cedricvogel-leo merged commit 592bba9 into main Nov 1, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant